# Write the relevant subset of the %m hash to local disk
{
    require Data::Dumper;
    $Data::Dumper::Indent = 1;
    $Data::Dumper::Quotekeys = 0;
    my $out = {};
    my @keys = $hostname;
    my @next;
    do {
	@next = ();
	for (@keys)
	{
	    next unless exists $m{$_};
	    next if exists $out->{$_};
	    $out->{$_} = $m{$_};

	    push @next, classes($_);
	}
    } while (@keys = @next);

    $_ = Data::Dumper->Dump([$out]);
    s/^.*/use Rollout;\nour \$hostname = '$hostname';\nour %m = (/;
    s/};$/);/;

    # force a traling comma
    1 while s/([^,])(\n\s*[]})])/$1,$2/g;

    # compress single value hash/arrays onto one line
    s/{\s+([^[{,]+),\s+}/{ $1 }/g;
    s/\[\s+([^[{,]+),\s+\]/[ $1 ]/g;

    text_install('/etc/machine', $_);
}

1;
